package com.ruoyi.cms.controller.portal;

import com.ruoyi.cms.entity.domain.ModelParameter;
import com.ruoyi.common.annotation.AllowAnonymous;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.cms.service.ModelParameterService;

/**
 * 模型参数
 */
@RestController
@RequestMapping("/portal/cms/parameter")
public class ModelParameterController {

    @Autowired
    private ModelParameterService modelParameterService;

    /**
     * 获取模型参数
     */
    @AllowAnonymous
    @GetMapping("/get/{modelId}")
    public R<ModelParameter> get(@PathVariable("modelId") Long modelId) {
        return R.ok(modelParameterService.get(modelId));
    }

    /**
     * 修改模型参数
     */
    @PostMapping("/update")
    public R<?> update(@RequestBody ModelParameter modelParameter) {
        return modelParameterService.update(modelParameter, true);
    }

    /**
     * 修改模型参数（内部调整）
     */
    @PostMapping("/updateNotAuth")
    @AllowAnonymous
    public R<?> updateNotAuth(@RequestBody ModelParameter modelParameter) {
        return modelParameterService.update(modelParameter, false);
    }

}
